Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | ACADEMIC RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * PROJECT METADATA8 * -----------------------------------------------------------------------------9 * Project : UQO Éval10 * File : src/app/municipalite/[slug]/page.tsx11 * Module : app12 * Repository : https://git.spboucher.ai/uqo-eval13 * Project Website : https://www.uqo-eval.app14 * Created : 2026-08-1315 * Last Modified : 2026-10-2816 *17 * =============================================================================18 * SOFTWARE MAINTAINER & AFFILIATION19 * =============================================================================20 *21 * Maintainer : Simon-Pierre Boucher22 * Position : Professor of Finance23 * Institution : Université du Québec en Outaouais (UQO)24 * Department : Département des sciences administratives25 * Website : https://spboucher.ai26 * Git : https://git.spboucher.ai27 *28 * Research Contact : research@spboucher.ai29 * Direct Contact : simon@spboucher.ai30 * Security/Admin : admin@spboucher.ai31 *32 * The affiliation is descriptive. It is not an institutional endorsement,33 * a license grant or a determination of ownership.34 *35 * =============================================================================36 * COPYRIGHT, AUTHORSHIP & DATA37 * =============================================================================38 *39 * Copyright (c) the author(s) of this work.40 * Ownership is not asserted by this notice; see the repository records.41 *42 * This header identifies the maintainer of the software. Scientific43 * authorship of any associated paper is stated in the paper itself and44 * is not changed by this notice. Datasets and third-party materials45 * remain the property of their respective owners and licensors.46 *47 * This file is governed by the applicable project license, copyright48 * notices, institutional agreements and relevant law.49 *50 * =============================================================================51 * LICENSE & MAINTENANCE52 * =============================================================================53 *54 * License : None specified (no license file in this repository)55 * Classification : Public56 *57 * =============================================================================58 * END OF SP BOUCHER SOURCE HEADER59 * =============================================================================60 */6162// UQO Éval — laboratoire pédagogique d'évaluation immobilière63// Page programmatique par municipalité : stats, répartition par type,64// fiches en HTML (maillage vers /estimation/[id]) et municipalités voisines.65import type { Metadata } from "next";66import Link from "next/link";67import { notFound } from "next/navigation";68import DownloadMenu from "@/components/DownloadMenu";69import {70 munBySlug,71 munStats,72 neighborMunicipalities,73 sampleUnits,74} from "@/lib/municipalites";75import {76 EST_YEAR,77 SITE_URL,78 TYPE_LABELS,79 TYPE_SLUGS,80 moneyFr,81 numFr,82} from "@/lib/seo";8384export const dynamic = "force-dynamic";8586export async function generateMetadata({87 params,88}: {89 params: Promise<{ slug: string }>;90}): Promise<Metadata> {91 const { slug } = await params;92 const mun = munBySlug(slug);93 if (!mun) return { title: "Municipalité introuvable" };94 const s = munStats(mun.nom)!;95 const title = `Valeur des propriétés à ${mun.nom} — médiane ${moneyFr(s.mediane2026)} (${EST_YEAR})`;96 const description = `${numFr(s.n)} propriétés évaluées à ${mun.nom} : valeur médiane estimée ${moneyFr(97 s.mediane202698 )}, croissance ${s.croissancePct == null ? "—" : `${s.croissancePct.toFixed(1).replace(".", ",")} %`} depuis 2021. Maisons, plex, condos, chalets et terrains — estimation gratuite par adresse.`;99 return {100 title,101 description,102 alternates: { canonical: `/municipalite/${slug}` },103 openGraph: { title, description, type: "website" },104 };105}106107export default async function MunicipalitePage({108 params,109}: {110 params: Promise<{ slug: string }>;111}) {112 const { slug } = await params;113 const mun = munBySlug(slug);114 if (!mun) notFound();115 const s = munStats(mun.nom)!;116 const samples = sampleUnits(mun.nom, null, 24);117 const voisines = neighborMunicipalities(mun.nom, 10);118 const url = `${SITE_URL}/municipalite/${slug}`;119120 const jsonLd = {121 "@context": "https://schema.org",122 "@graph": [123 {124 "@type": "City",125 "@id": `${url}#place`,126 name: mun.nom,127 url,128 geo: { "@type": "GeoCoordinates", latitude: mun.lat, longitude: mun.lng },129 containedInPlace: { "@type": "AdministrativeArea", name: "Québec, Canada" },130 },131 {132 "@type": "BreadcrumbList",133 itemListElement: [134 { "@type": "ListItem", position: 1, name: "Accueil", item: SITE_URL },135 { "@type": "ListItem", position: 2, name: "Municipalités", item: `${SITE_URL}/municipalites` },136 { "@type": "ListItem", position: 3, name: mun.nom, item: url },137 ],138 },139 ],140 };141142 return (143 <div className="pb-6 pt-10 sm:pt-14">144 <script145 type="application/ld+json"146 dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}147 />148 <nav className="vp-mono text-[11px] uppercase tracking-[0.08em] text-ink-2">149 <Link href="/" className="hover:underline">150 Accueil151 </Link>{" "}152 /{" "}153 <Link href="/municipalites" className="hover:underline">154 Municipalités155 </Link>{" "}156 / <span className="text-ink">{mun.nom}</span>157 </nav>158159 <section className="mt-6">160 <span className="kicker">Municipalité · Québec</span>161 <h1 className="vp-display mt-3 max-w-4xl text-[clamp(28px,5.4vw,56px)] font-bold uppercase leading-[1.0] tracking-[-0.03em]">162 L'immobilier à <span className="hl">{mun.nom}</span>163 </h1>164 <p className="mt-4 max-w-2xl text-[15.5px] text-ink-2">165 {numFr(s.n)} unités d'évaluation au rôle foncier {EST_YEAR},166 estimées par le modèle UQO Éval (modèle hédonique + ventes réelles).167 Cherchez n'importe quelle adresse de {mun.nom} depuis{" "}168 <Link href="/" className="underline">169 l'accueil170 </Link>{" "}171 ou explorez{" "}172 <Link href="/carte" className="underline">173 la carte174 </Link>175 .176 </p>177 </section>178179 <div className="mt-5"><DownloadMenu kind="municipalite" query={{ slug }} title={`L'immobilier à ${mun.nom}`} /></div>180181 {/* ---- Tuiles statistiques ---- */}182 <section className="mt-8 grid grid-cols-2 gap-3 lg:grid-cols-4">183 {[184 ["Propriétés évaluées", numFr(s.n)],185 [`Valeur médiane ${EST_YEAR}`, moneyFr(s.mediane2026)],186 [`Valeur totale ${EST_YEAR}`, moneyFr(s.total2026)],187 [188 "Croissance 2021 → 2026",189 s.croissancePct == null190 ? "—"191 : `${s.croissancePct >= 0 ? "+" : ""}${s.croissancePct.toFixed(1).replace(".", ",")} %`,192 ],193 ].map(([label, val]) => (194 <div key={label} className="vp-card p-4">195 <p className="klabel">{label}</p>196 <p className="vp-display mt-1 break-words text-[clamp(17px,2.2vw,26px)] font-bold tracking-[-0.02em]">197 {val}198 </p>199 </div>200 ))}201 </section>202203 {/* ---- Répartition par type ---- */}204 <section className="mt-12">205 <span className="kicker">Par type de propriété</span>206 <h2 className="vp-display mt-3 text-[clamp(20px,3vw,30px)] font-bold uppercase tracking-[-0.02em]">207 Médianes par type à {mun.nom}208 </h2>209 <div className="mt-5 overflow-x-auto">210 <table className="w-full min-w-[560px] border-collapse text-[14px]">211 <thead>212 <tr className="border-b-2 border-ink text-left">213 <th className="klabel py-2 pr-4">Type</th>214 <th className="klabel py-2 pr-4 text-right">Propriétés</th>215 <th className="klabel py-2 pr-4 text-right">Médiane {EST_YEAR}</th>216 <th className="klabel py-2 text-right">Valeur totale</th>217 </tr>218 </thead>219 <tbody>220 {s.parType.map((t) => (221 <tr key={t.type} className="border-b border-[rgba(20,24,20,0.12)]">222 <td className="py-2.5 pr-4">223 <Link224 href={`/municipalite/${slug}/${TYPE_SLUGS[t.type] ?? t.type}`}225 className="font-medium underline decoration-[rgba(20,24,20,0.3)] underline-offset-2 hover:decoration-ink"226 >227 {TYPE_LABELS[t.type]?.pluriel ?? t.type}228 </Link>229 </td>230 <td className="vp-mono py-2.5 pr-4 text-right">{numFr(t.n)}</td>231 <td className="vp-mono py-2.5 pr-4 text-right">232 {moneyFr(t.mediane2026)}233 </td>234 <td className="vp-mono py-2.5 text-right">{moneyFr(t.total2026)}</td>235 </tr>236 ))}237 </tbody>238 </table>239 </div>240 </section>241242 {/* ---- Propriétés les plus valorisées (liens indexables) ---- */}243 {samples.length > 0 && (244 <section className="mt-12">245 <span className="kicker">Aperçu du registre</span>246 <h2 className="vp-display mt-3 text-[clamp(20px,3vw,30px)] font-bold uppercase tracking-[-0.02em]">247 Propriétés les plus valorisées à {mun.nom}248 </h2>249 <ul className="mt-5 grid gap-x-6 gap-y-1.5 sm:grid-cols-2">250 {samples.map((u) => (251 <li key={u.id_provinc}>252 <Link253 href={`/estimation/${encodeURIComponent(u.id_provinc)}`}254 className="group flex items-baseline justify-between gap-3 border-b border-[rgba(20,24,20,0.12)] py-1.5 text-[13.5px]"255 >256 <span className="truncate group-hover:underline">257 {u.adresse}258 {u.apt ? `, app. ${u.apt}` : ""}259 </span>260 <span className="vp-mono shrink-0 text-[11px] text-ink-2">261 {moneyFr(u.est_2026)}262 </span>263 </Link>264 </li>265 ))}266 </ul>267 <p className="mt-4 text-[13px] text-ink-2">268 Chaque adresse de {mun.nom} a sa fiche : estimation {EST_YEAR},269 fourchette P10-P90, historique 2021-{EST_YEAR} et comparables réels.270 </p>271 </section>272 )}273274 {/* ---- Municipalités voisines ---- */}275 {voisines.length > 0 && (276 <section className="mt-12">277 <span className="kicker">À proximité</span>278 <h2 className="vp-display mt-3 text-[clamp(20px,3vw,30px)] font-bold uppercase tracking-[-0.02em]">279 Municipalités voisines280 </h2>281 <ul className="mt-4 flex flex-wrap gap-2">282 {voisines.map((v) => (283 <li key={v.slug}>284 <Link285 href={`/municipalite/${v.slug}`}286 className="stat-chip transition-colors hover:text-accent-deep"287 >288 {v.nom}289 </Link>290 </li>291 ))}292 </ul>293 </section>294 )}295 </div>296 );297}298